<?php echo $header; ?>
<style type="text/css">
    table.permission tr td{
        font-size:10px;
        text-align:center;
        width:30px;
        padding:2px;
    }
    .list thead td{
        height:50px;
    }
    table.permission tr td.permission-group{
        height:30px;
        text-align:left;
        padding:7px;
    }
</style>
<div id="content">
    <div class="breadcrumb">
        <?php foreach ($breadcrumbs as $breadcrumb) { ?>
        <?php echo $breadcrumb['separator']; ?><a href="<?php echo $breadcrumb['href']; ?>"><?php echo $breadcrumb['text']; ?></a>
        <?php } ?>
    </div>
    <?php if ($error_warning) { ?>
    <div class="warning"><?php echo $error_warning; ?></div>
    <?php } ?>
    <div class="box">
        <div class="heading">
            <h1><img src="view/image/category.png" alt="" /> <?php echo $heading_title; ?></h1>
            <div class="buttons"><a onclick="$('#form').submit();" class="button"><?php echo $button_save; ?></a><a onclick="location = '<?php echo $cancel; ?>';" class="button"><?php echo $button_cancel; ?></a></div>
        </div>
        <div class="content">
            <div id="tabs" class="htabs"><a href="#tab-general"><?php echo $tab_general; ?></a><a class="tag_per"<?php echo $type ? '' :' style="visibility:hidden;"' ?> href="#tab-tag"><?php echo $tab_tag; ?></a><a class="tag_per"<?php echo $type ? '' :' style="visibility:hidden;"' ?> href="#tab-permission"><?php echo $tab_permission; ?></a></div>
            <form action="<?php echo $action; ?>" method="post" enctype="multipart/form-data" id="form">
                <div id="tab-general">
                    <table class="form">
                        <tr>
                            <td><?php echo $entry_type; ?></td>
                            <td><select name="type">
                                <?php if ($type) { ?>
                                <option value="0"><?php echo $text_category; ?></option>
                                <option value="1" selected="selected"><?php echo $text_forum; ?></option>
                                <?php } else { ?>
                                <option value="0" selected="selected"><?php echo $text_category; ?></option>
                                <option value="1"><?php echo $text_forum; ?></option>
                                <?php } ?>
                            </select></td>
                        </tr>
                        <tr class="optional"<?php echo $type ? '' :' style="display:none;"' ?>>
                            <td><?php echo $entry_category; ?></td>
                            <td><select name="category_id">
                                <option value="0"><?php echo $text_none; ?></option>
                                <?php foreach ($categories as $category) { ?>
                                <?php if ($category['forum_id'] == $category_id) { ?>
                                    <option value="<?php echo $category['forum_id']; ?>" selected="selected"><?php echo $category['forum_name']; ?></option>
                                    <?php } else { ?>
                                    <option value="<?php echo $category['forum_id']; ?>"><?php echo $category['forum_name']; ?></option>
                                    <?php } ?>
                                <?php } ?>
                            </select></td>
                        </tr>
                        <tr class="optional" <?php echo $type ? '' :' style="display:none;"' ?>>
                            <td><?php echo $entry_parent; ?></td>
                            <td><select name="parent_id">
                                <option value="0"><?php echo $text_none; ?></option>
                                <?php foreach ($parent_forums as $parent_forum) { ?>
                                <?php if ($parent_forum['forum_id'] == $parent_id) { ?>
                                    <option value="<?php echo $parent_forum['forum_id']; ?>" selected="selected"><?php echo $parent_forum['forum_name']; ?></option>
                                    <?php } else { ?>
                                    <option value="<?php echo $parent_forum['forum_id']; ?>"><?php echo $parent_forum['forum_name']; ?></option>
                                    <?php } ?>
                                <?php } ?>
                            </select></td>
                        </tr>
                        <tr>
                            <td><?php echo $entry_sort_order; ?></td>
                            <td><input type="text" name="sort_order" value="<?php echo $sort_order; ?>" size="1" /></td>
                        </tr>
                        <tr>
                            <td><?php echo $entry_status; ?></td>
                            <td><select name="status">
                                <?php if ($status) { ?>
                                <option value="1" selected="selected"><?php echo $text_enabled; ?></option>
                                <option value="0"><?php echo $text_disabled; ?></option>
                                <?php } else { ?>
                                <option value="1"><?php echo $text_enabled; ?></option>
                                <option value="0" selected="selected"><?php echo $text_disabled; ?></option>
                                <?php } ?>
                            </select></td>
                        </tr>
                        <?php if($type){ ?>
                        <tr class="optional"<?php echo $type ? '' :' style="display:none;"' ?>>
                            <td><?php echo $entry_mod; ?></td>
                            <?php if($forum_mods){ ?>
                            <td>
                                <?php foreach($forum_mods as $forum_mod){ ?>
                                <?php echo $forum_mod['mod_name']; ?>&nbsp;&nbsp;<input style="width: 16px; height: 16px; border: 1px; text-indent:9999px; cursor:pointer; background-image: url('view/image/delete.png');" type="submit" name="remove_mod" value="<?php echo $forum_mod['mod_id']; ?>" />&nbsp;&nbsp;
                                <?php } ?>
                            </td>
                            <?php }else{ ?>
                            <td>
                                <?php echo $text_none; ?>
                            </td>
                            <?php } ?>
                        </tr>
                        <tr class="optional"<?php echo $type ? '' :' style="display:none;"' ?>>
                            <td><?php echo $entry_add_mod; ?></td>
                            <td><input type="text" name="forum_mod_name" value="" />&nbsp;&nbsp;<input style="padding: 3px 15px 3px 15px;background: #003A88;border: 0;color: #FFF; cursor:pointer;" type="submit" value="<?php echo $button_add; ?>" name="add_mod" /> </td>
                        </tr>
                        <?php } ?>
                    </table>
                    <div id="languages" class="htabs">
                        <?php foreach ($languages as $language) { ?>
                        <a href="#language<?php echo $language['language_id']; ?>"><img src="view/image/flags/<?php echo $language['image']; ?>" title="<?php echo $language['name']; ?>" /> <?php echo $language['name']; ?></a>
                        <?php } ?>
                    </div>
                    <?php foreach ($languages as $language) { ?>
                    <div id="language<?php echo $language['language_id']; ?>">
                        <input type="hidden" name="language_ids[]" value="<?php echo $language['language_id']; ?>" />
                        <table class="form">
                            <tr>
                                <td><span class="required">*</span> <?php echo $entry_name; ?></td>
                                <td><input type="text" name="name[<?php echo $language['language_id']; ?>]" size="100" value="<?php echo isset($name[$language['language_id']]) ? $name[$language['language_id']] : ''; ?>" />
                                    <?php if (isset($error_name[$language['language_id']])) { ?>
                                        <span class="error"><?php echo $error_name[$language['language_id']]; ?></span>
                                        <?php } ?></td>
                            </tr>
                            <tr class="optional" <?php echo $type ? '' :' style="display:none;"' ?>>
                                <td><?php echo $entry_description; ?></td>
                                <td><textarea style="width:530px; height:200px;" name="description[<?php echo $language['language_id']; ?>]"><?php echo isset($description[$language['language_id']]) ? $description[$language['language_id']] : ''; ?></textarea></td>
                            </tr>
                            <tr class="optional" <?php echo $type ? '' :' style="display:none;"' ?>>
                                <td><?php echo $entry_rule; ?></td>
                                <td><textarea name="rule[<?php echo $language['language_id']; ?>]" id="rule<?php echo $language['language_id']; ?>"><?php echo isset($rule[$language['language_id']]) ? $rule[$language['language_id']] : ''; ?></textarea></td>
                            </tr>
                        </table>
                    </div>
                    <?php } ?>
                </div>
                <div class="tag_per"<?php echo $type ? '' :' style="visibility:hidden;"' ?> id="tab-tag">
                    <table class="form">
                        <tr>
                            <td><?php echo $entry_topic_category_status; ?></td>
                            <td><select name="topic_category_enabled">
                                <?php if ($topic_category_enabled) { ?>
                                <option value="1" selected="selected"><?php echo $text_enabled; ?></option>
                                <option value="0"><?php echo $text_disabled; ?></option>
                                <?php } else { ?>
                                <option value="1"><?php echo $text_enabled; ?></option>
                                <option value="0" selected="selected"><?php echo $text_disabled; ?></option>
                                <?php } ?>
                            </select></td>
                        </tr>
                        <tr>
                            <td><?php echo $entry_topic_category_displayed; ?></td>
                            <td><select name="topic_category_displayed">
                                <?php if ($topic_category_displayed) { ?>
                                <option value="1" selected="selected"><?php echo $text_enabled; ?></option>
                                <option value="0"><?php echo $text_disabled; ?></option>
                                <?php } else { ?>
                                <option value="1"><?php echo $text_enabled; ?></option>
                                <option value="0" selected="selected"><?php echo $text_disabled; ?></option>
                                <?php } ?>
                            </select></td>
                        </tr>
                    </table>
                    <table id="topic-tag" class="list">
                        <thead>
                        <tr>
                            <td class="left"><span class="required">*</span> <?php echo $entry_tag; ?></td>
                            <td class="right"><?php echo $entry_sort_order; ?></td>
                            <td></td>
                        </tr>
                        </thead>
                        <?php $tag_row = 0; ?>
                        <?php foreach ($tags as $tag) { ?>
                        <tbody id="tag-row<?php echo $tag_row; ?>">
                        <tr>
                            <td class="left"><input type="hidden" name="tag[<?php echo $tag_row; ?>][topic_category_id]" value="<?php echo $tag['topic_category_id']; ?>" />
                                <?php foreach ($languages as $language) { ?>
                                    <input type="text" name="tag[<?php echo $tag_row; ?>][topic_category_title][<?php echo $language['language_id']; ?>]" value="<?php echo isset($tag['topic_category_title'][$language['language_id']]) ? $tag['topic_category_title'][$language['language_id']] : ''; ?>" />
                                    <img src="view/image/flags/<?php echo $language['image']; ?>" title="<?php echo $language['name']; ?>" /><br />
                                    <?php if (isset($error_tag[$tag_row][$language['language_id']])) { ?>
                                        <span class="error"><?php echo $error_tag[$tag_row][$language['language_id']]; ?></span>
                                        <?php } ?>
                                    <?php } ?></td>
                            <td class="right"><input type="text" name="tag[<?php echo $tag_row; ?>][sort_order_id]" value="<?php echo $tag['sort_order_id']; ?>" size="1" /></td>
                            <td class="left"><a onclick="$('#tag-row<?php echo $tag_row; ?>').remove();" class="button"><?php echo $button_remove; ?></a></td>
                        </tr>
                        </tbody>
                        <?php $tag_row++; ?>
                        <?php } ?>
                        <tfoot>
                        <tr>
                            <td colspan="2"></td>
                            <td class="left"><a onclick="addTag();" class="button"><?php echo $button_add; ?></a></td>
                        </tr>
                        </tfoot>
                    </table>
                </div>
                <div class="tag_per"<?php echo $type ? '' :' style="visibility:hidden;"' ?> id="tab-permission">
                    <table class="list permission">
                        <thead>
                        <tr>
                            <td class="left"><?php echo $entry_administrative_permission; ?></td>
                            <td><input type="checkbox" name="" value="" /></td>
                            <td><input type="checkbox" name="" value="" /></td>
                            <td><input type="checkbox" name="" value="" /></td>
                            <td><input type="checkbox" name="" value="" /></td>
                            <td><input type="checkbox" name="" value="" /></td>
                            <td><input type="checkbox" name="" value="" /></td>
                            <td><input type="checkbox" name="" value="" /></td>
                            <td><input type="checkbox" name="" value="" /></td>
                            <td><input type="checkbox" name="" value="" /></td>
                            <td><input type="checkbox" name="" value="" /></td>
                            <td><input type="checkbox" name="" value="" /></td>
                            <td><input type="checkbox" name="" value="" /></td>
                            <td><input type="checkbox" name="" value="" /></td>
                            <td></td>
                            <td></td>
                        </tr>
                        </thead>
                        <tbody>
                        <tr>
                            <td></td>
                            <td><?php echo $entry_topic_announcement; ?></td>
                            <td><?php echo $entry_topic_global_announcement; ?></td>
                            <td><?php echo $entry_topic_featured; ?></td>
                            <td><?php echo $entry_topic_sticky; ?></td>
                            <td><?php echo $entry_topic_move; ?></td>
                            <td><?php echo $entry_topic_lock; ?></td>
                            <td><?php echo $entry_topic_solve; ?></td>
                            <td><?php echo $entry_topic_unsolve; ?></td>
                            <td><?php echo $entry_edit_lock; ?></td>
                            <td><?php echo $entry_post_approve; ?></td>
                            <td><?php echo $entry_post_recycle_bin_clear; ?></td>
                            <td><?php echo $entry_post_members_edit; ?></td>
                            <td><?php echo $entry_post_members_delete; ?></td>
                            <td></td>
                            <td></td>
                        </tr>
                        <?php if($administrative_permissions){ ?>
                        <?php foreach ($administrative_permissions as $administrative_permission) { ?>
                        <tr>
                            <td class="left">
                                <input type="checkbox" name="" value="1" />
                                <?php echo $administrative_permission['role_title']; ?>
                                <input type="hidden" name="administrative_permission[<?php echo $administrative_permission['role_id']; ?>][role_title]" value="<?php echo $administrative_permission['role_title']; ?>" />
                                <input type="hidden" name="administrative_permission[<?php echo $administrative_permission['role_id']; ?>][role_id]" value="<?php echo $administrative_permission['role_id']; ?>" />
                                <input type="hidden" name="administrative_permission[<?php echo $administrative_permission['role_id']; ?>][rank_id]" value="<?php echo $administrative_permission['rank_id']; ?>" />
                            </td>
                            <td><input type="checkbox" name="administrative_permission[<?php echo $administrative_permission['role_id']; ?>][topic_announcement]" value="1" <?php echo isset($administrative_permission['topic_announcement']) && $administrative_permission['topic_announcement'] ? 'checked="checked"' : ''; ?> /></td>
                            <td><input type="checkbox" name="administrative_permission[<?php echo $administrative_permission['role_id']; ?>][topic_global_announcement]" value="1" <?php echo isset($administrative_permission['topic_global_announcement']) && $administrative_permission['topic_global_announcement'] ? 'checked="checked"' : ''; ?> /></td>
                            <td><input type="checkbox" name="administrative_permission[<?php echo $administrative_permission['role_id']; ?>][topic_featured]" value="1" <?php echo isset($administrative_permission['topic_featured']) && $administrative_permission['topic_featured'] ? 'checked="checked"' : ''; ?> /></td>
                            <td><input type="checkbox" name="administrative_permission[<?php echo $administrative_permission['role_id']; ?>][topic_sticky]" value="1" <?php echo isset($administrative_permission['topic_sticky']) && $administrative_permission['topic_sticky'] ? 'checked="checked"' : ''; ?> /></td>
                            <td><input type="checkbox" name="administrative_permission[<?php echo $administrative_permission['role_id']; ?>][topic_move]" value="1" <?php echo isset($administrative_permission['topic_move']) && $administrative_permission['topic_move'] ? 'checked="checked"' : ''; ?> /></td>
                            <td><input type="checkbox" name="administrative_permission[<?php echo $administrative_permission['role_id']; ?>][topic_lock]" value="1" <?php echo isset($administrative_permission['topic_lock']) && $administrative_permission['topic_lock'] ? 'checked="checked"' : ''; ?> /></td>
                            <td><input type="checkbox" name="administrative_permission[<?php echo $administrative_permission['role_id']; ?>][topic_solve]" value="1" <?php echo isset($administrative_permission['topic_solve']) && $administrative_permission['topic_solve'] ? 'checked="checked"' : ''; ?> /></td>
                            <td><input type="checkbox" name="administrative_permission[<?php echo $administrative_permission['role_id']; ?>][topic_unsolve]" value="1" <?php echo isset($administrative_permission['topic_unsolve']) && $administrative_permission['topic_unsolve'] ? 'checked="checked"' : ''; ?> /></td>
                            <td><input type="checkbox" name="administrative_permission[<?php echo $administrative_permission['role_id']; ?>][edit_lock]" value="1" <?php echo isset($administrative_permission['edit_lock']) && $administrative_permission['edit_lock'] ? 'checked="checked"' : ''; ?> /></td>
                            <td><input type="checkbox" name="administrative_permission[<?php echo $administrative_permission['role_id']; ?>][post_approve]" value="1" <?php echo isset($administrative_permission['post_approve']) && $administrative_permission['post_approve'] ? 'checked="checked"' : ''; ?> /></td>
                            <td><input type="checkbox" name="administrative_permission[<?php echo $administrative_permission['role_id']; ?>][post_recycle_bin_clear]" value="1" <?php echo isset($administrative_permission['post_recycle_bin_clear']) && $administrative_permission['post_recycle_bin_clear'] ? 'checked="checked"' : ''; ?> /></td>
                            <td><input type="checkbox" name="administrative_permission[<?php echo $administrative_permission['role_id']; ?>][post_members_edit]" value="1" <?php echo isset($administrative_permission['post_members_edit']) && $administrative_permission['post_members_edit'] ? 'checked="checked"' : ''; ?> /></td>
                            <td><input type="checkbox" name="administrative_permission[<?php echo $administrative_permission['role_id']; ?>][post_members_delete]" value="1" <?php echo isset($administrative_permission['post_members_delete']) && $administrative_permission['post_members_delete'] ? 'checked="checked"' : ''; ?> /></td>
                            <td></td>
                            <td></td>
                        </tr>
                        <?php } ?>
                        <?php } ?>
                        </tbody>
                        <thead>
                        <tr>
                            <td class="left"><?php echo $entry_common_permission; ?></td>
                            <td><input type="checkbox" name="" value="" /></td>
                            <td><input type="checkbox" name="" value="" /></td>
                            <td><input type="checkbox" name="" value="" /></td>
                            <td><input type="checkbox" name="" value="" /></td>
                            <td><input type="checkbox" name="" value="" /></td>
                            <td><input type="checkbox" name="" value="" /></td>
                            <td><input type="checkbox" name="" value="" /></td>
                            <td><input type="checkbox" name="" value="" /></td>
                            <td><input type="checkbox" name="" value="" /></td>
                            <td><input type="checkbox" name="" value="" /></td>
                            <td><input type="checkbox" name="" value="" /></td>
                            <td><input type="checkbox" name="" value="" /></td>
                            <td><input type="checkbox" name="" value="" /></td>
                            <td><input type="checkbox" name="" value="" /></td>
                            <td><input type="checkbox" name="" value="" /></td>
                        </tr>
                        </thead>
                        <tbody>
                        <tr>
                            <td></td>
                            <td><?php echo $entry_view_forum; ?></td>
                            <td><?php echo $entry_topic_view; ?></td>
                            <td><?php echo $entry_topic_publish; ?></td>
                            <td><?php echo $entry_topic_reply; ?></td>
                            <td><?php echo $entry_post_delete; ?></td>
                            <td><?php echo $entry_post_edit; ?></td>
                            <td><?php echo $entry_poll_publish; ?></td>
                            <td><?php echo $entry_poll_edit; ?></td>
                            <td><?php echo $entry_poll_vote; ?></td>
                            <td><?php echo $entry_posting_approval; ?></td>
                            <td><?php echo $entry_posting_bbcode; ?></td>
                            <td><?php echo $entry_posting_bbcode_img; ?></td>
                            <td><?php echo $entry_posting_bbcode_flash; ?></td>
                            <td><?php echo $entry_posting_bbcode_url; ?></td>
                            <td><?php echo $entry_posting_smiles; ?></td>
                        </tr>
                        <?php if($admin_common_permissions){ ?>
                        <tr>
                            <td class="permission-group" colspan="16"><strong><?php echo $entry_administrative_group; ?></strong></td>
                        </tr>
                        <?php foreach ($admin_common_permissions as $admin_common_permission) { ?>
                        <tr>
                            <td class="left">
                                <input type="checkbox" name="" value="1" />
                                <?php echo $admin_common_permission['role_title']; ?>
                                <input type="hidden" name="admin_common_permission[<?php echo $admin_common_permission['role_id']; ?>][role_title]" value="<?php echo $admin_common_permission['role_title']; ?>" />
                                <input type="hidden" name="admin_common_permission[<?php echo $admin_common_permission['role_id']; ?>][role_id]" value="<?php echo $admin_common_permission['role_id']; ?>" />
                                <input type="hidden" name="admin_common_permission[<?php echo $admin_common_permission['role_id']; ?>][rank_id]" value="<?php echo $admin_common_permission['rank_id']; ?>" />
                            </td>
                            <td><input type="checkbox" name="admin_common_permission[<?php echo $admin_common_permission['role_id']; ?>][view_forum]" value="1" <?php echo isset($admin_common_permission['view_forum']) && $admin_common_permission['view_forum'] ? 'checked="checked"' : ''; ?> /></td>
                            <td><input type="checkbox" name="admin_common_permission[<?php echo $admin_common_permission['role_id']; ?>][topic_view]" value="1" <?php echo isset($admin_common_permission['topic_view']) && $admin_common_permission['topic_view'] ? 'checked="checked"' : ''; ?> /></td>
                            <td><input type="checkbox" name="admin_common_permission[<?php echo $admin_common_permission['role_id']; ?>][topic_publish]" value="1" <?php echo isset($admin_common_permission['topic_publish']) && $admin_common_permission['topic_publish'] ? 'checked="checked"' : ''; ?> /></td>
                            <td><input type="checkbox" name="admin_common_permission[<?php echo $admin_common_permission['role_id']; ?>][topic_reply]" value="1" <?php echo isset($admin_common_permission['topic_reply']) && $admin_common_permission['topic_reply'] ? 'checked="checked"' : ''; ?> /></td>
                            <td><input type="checkbox" name="admin_common_permission[<?php echo $admin_common_permission['role_id']; ?>][post_delete]" value="1" <?php echo isset($admin_common_permission['post_delete']) && $admin_common_permission['post_delete'] ? 'checked="checked"' : ''; ?> /></td>
                            <td><input type="checkbox" name="admin_common_permission[<?php echo $admin_common_permission['role_id']; ?>][post_edit]" value="1" <?php echo isset($admin_common_permission['post_edit']) && $admin_common_permission['post_edit'] ? 'checked="checked"' : ''; ?> /></td>
                            <td><input type="checkbox" name="admin_common_permission[<?php echo $admin_common_permission['role_id']; ?>][poll_publish]" value="1" <?php echo isset($admin_common_permission['poll_publish']) && $admin_common_permission['poll_publish'] ? 'checked="checked"' : ''; ?> /></td>
                            <td><input type="checkbox" name="admin_common_permission[<?php echo $admin_common_permission['role_id']; ?>][poll_edit]" value="1" <?php echo isset($admin_common_permission['poll_edit']) && $admin_common_permission['poll_edit'] ? 'checked="checked"' : ''; ?> /></td>
                            <td><input type="checkbox" name="admin_common_permission[<?php echo $admin_common_permission['role_id']; ?>][poll_vote]" value="1" <?php echo isset($admin_common_permission['poll_vote']) && $admin_common_permission['poll_vote'] ? 'checked="checked"' : ''; ?> /></td>
                            <td><input type="checkbox" name="admin_common_permission[<?php echo $admin_common_permission['role_id']; ?>][posting_approval]" value="1" <?php echo isset($admin_common_permission['posting_approval']) && $admin_common_permission['posting_approval'] ? 'checked="checked"' : ''; ?> /></td>
                            <td><input type="checkbox" name="admin_common_permission[<?php echo $admin_common_permission['role_id']; ?>][posting_bbcode]" value="1" <?php echo isset($admin_common_permission['posting_bbcode']) && $admin_common_permission['posting_bbcode'] ? 'checked="checked"' : ''; ?> /></td>
                            <td><input type="checkbox" name="admin_common_permission[<?php echo $admin_common_permission['role_id']; ?>][posting_bbcode_img]" value="1" <?php echo isset($admin_common_permission['posting_bbcode_img']) && $admin_common_permission['posting_bbcode_img'] ? 'checked="checked"' : ''; ?> /></td>
                            <td><input type="checkbox" name="admin_common_permission[<?php echo $admin_common_permission['role_id']; ?>][posting_bbcode_flash]" value="1" <?php echo isset($admin_common_permission['posting_bbcode_flash']) && $admin_common_permission['posting_bbcode_flash'] ? 'checked="checked"' : ''; ?> /></td>
                            <td><input type="checkbox" name="admin_common_permission[<?php echo $admin_common_permission['role_id']; ?>][posting_bbcode_url]" value="1" <?php echo isset($admin_common_permission['posting_bbcode_url']) && $admin_common_permission['posting_bbcode_url'] ? 'checked="checked"' : ''; ?> /></td>
                            <td><input type="checkbox" name="admin_common_permission[<?php echo $admin_common_permission['role_id']; ?>][posting_smiles]" value="1" <?php echo isset($admin_common_permission['posting_smiles']) && $admin_common_permission['posting_smiles'] ? 'checked="checked"' : ''; ?> /></td>
                        </tr>
                        <?php } ?>
                        <?php } ?>
                        <?php if($other_group_common_permissions){ ?>
                        <tr>
                            <td class="permission-group" colspan="16"><strong><?php echo $entry_other_group; ?></strong></td>
                        </tr>
                        <?php foreach ($other_group_common_permissions as $other_group_common_permission) { ?>
                        <tr>
                            <td class="left">
                                <input type="checkbox" name="" value="1" />
                                <?php echo $other_group_common_permission['role_title']; ?>
                                <input type="hidden" name="other_group_common_permission[<?php echo $other_group_common_permission['role_id']; ?>][role_title]" value="<?php echo $other_group_common_permission['role_title']; ?>" />
                                <input type="hidden" name="other_group_common_permission[<?php echo $other_group_common_permission['role_id']; ?>][role_id]" value="<?php echo $other_group_common_permission['role_id']; ?>" />
                                <input type="hidden" name="other_group_common_permission[<?php echo $other_group_common_permission['role_id']; ?>][rank_id]" value="<?php echo $other_group_common_permission['rank_id']; ?>" />
                            </td>
                            <td><input type="checkbox" name="other_group_common_permission[<?php echo $other_group_common_permission['role_id']; ?>][view_forum]" value="1" <?php echo isset($other_group_common_permission['view_forum']) && $other_group_common_permission['view_forum'] ? 'checked="checked"' : ''; ?> /></td>
                            <td><input type="checkbox" name="other_group_common_permission[<?php echo $other_group_common_permission['role_id']; ?>][topic_view]" value="1" <?php echo isset($other_group_common_permission['topic_view']) && $other_group_common_permission['topic_view'] ? 'checked="checked"' : ''; ?> /></td>
                            <td><input type="checkbox" name="other_group_common_permission[<?php echo $other_group_common_permission['role_id']; ?>][topic_publish]" value="1" <?php echo isset($other_group_common_permission['topic_publish']) && $other_group_common_permission['topic_publish'] ? 'checked="checked"' : ''; ?> /></td>
                            <td><input type="checkbox" name="other_group_common_permission[<?php echo $other_group_common_permission['role_id']; ?>][topic_reply]" value="1" <?php echo isset($other_group_common_permission['topic_reply']) && $other_group_common_permission['topic_reply'] ? 'checked="checked"' : ''; ?> /></td>
                            <td><input type="checkbox" name="other_group_common_permission[<?php echo $other_group_common_permission['role_id']; ?>][post_delete]" value="1" <?php echo isset($other_group_common_permission['post_delete']) && $other_group_common_permission['post_delete'] ? 'checked="checked"' : ''; ?> /></td>
                            <td><input type="checkbox" name="other_group_common_permission[<?php echo $other_group_common_permission['role_id']; ?>][post_edit]" value="1" <?php echo isset($other_group_common_permission['post_edit']) && $other_group_common_permission['post_edit'] ? 'checked="checked"' : ''; ?> /></td>
                            <td><input type="checkbox" name="other_group_common_permission[<?php echo $other_group_common_permission['role_id']; ?>][poll_publish]" value="1" <?php echo isset($other_group_common_permission['poll_publish']) && $other_group_common_permission['poll_publish'] ? 'checked="checked"' : ''; ?> /></td>
                            <td><input type="checkbox" name="other_group_common_permission[<?php echo $other_group_common_permission['role_id']; ?>][poll_edit]" value="1" <?php echo isset($other_group_common_permission['poll_edit']) && $other_group_common_permission['poll_edit'] ? 'checked="checked"' : ''; ?> /></td>
                            <td><input type="checkbox" name="other_group_common_permission[<?php echo $other_group_common_permission['role_id']; ?>][poll_vote]" value="1" <?php echo isset($other_group_common_permission['poll_vote']) && $other_group_common_permission['poll_vote'] ? 'checked="checked"' : ''; ?> /></td>
                            <td><input type="checkbox" name="other_group_common_permission[<?php echo $other_group_common_permission['role_id']; ?>][posting_approval]" value="1" <?php echo isset($other_group_common_permission['posting_approval']) && $other_group_common_permission['posting_approval'] ? 'checked="checked"' : ''; ?> /></td>
                            <td><input type="checkbox" name="other_group_common_permission[<?php echo $other_group_common_permission['role_id']; ?>][posting_bbcode]" value="1" <?php echo isset($other_group_common_permission['posting_bbcode']) && $other_group_common_permission['posting_bbcode'] ? 'checked="checked"' : ''; ?> /></td>
                            <td><input type="checkbox" name="other_group_common_permission[<?php echo $other_group_common_permission['role_id']; ?>][posting_bbcode_img]" value="1" <?php echo isset($other_group_common_permission['posting_bbcode_img']) && $other_group_common_permission['posting_bbcode_img'] ? 'checked="checked"' : ''; ?> /></td>
                            <td><input type="checkbox" name="other_group_common_permission[<?php echo $other_group_common_permission['role_id']; ?>][posting_bbcode_flash]" value="1" <?php echo isset($other_group_common_permission['posting_bbcode_flash']) && $other_group_common_permission['posting_bbcode_flash'] ? 'checked="checked"' : ''; ?> /></td>
                            <td><input type="checkbox" name="other_group_common_permission[<?php echo $other_group_common_permission['role_id']; ?>][posting_bbcode_url]" value="1" <?php echo isset($other_group_common_permission['posting_bbcode_url']) && $other_group_common_permission['posting_bbcode_url'] ? 'checked="checked"' : ''; ?> /></td>
                            <td><input type="checkbox" name="other_group_common_permission[<?php echo $other_group_common_permission['role_id']; ?>][posting_smiles]" value="1" <?php echo isset($other_group_common_permission['posting_smiles']) && $other_group_common_permission['posting_smiles'] ? 'checked="checked"' : ''; ?> /></td>
                        </tr>
                        <?php } ?>
                        <?php } ?>
                        <?php if($user_defined_group_common_permissions){ ?>
                        <tr>
                            <td class="permission-group" colspan="16"><strong><?php echo $entry_user_defined_group; ?></strong></td>
                        </tr>
                        <?php foreach ($user_defined_group_common_permissions as $user_defined_group_common_permission) { ?>
                        <tr>
                            <td class="left">
                                <input type="checkbox" name="" value="1" />
                                <?php echo $user_defined_group_common_permission['role_title']; ?>
                                <input type="hidden" name="user_defined_group_common_permission[<?php echo $user_defined_group_common_permission['role_id']; ?>][role_title]" value="<?php echo $user_defined_group_common_permission['role_title']; ?>" />
                                <input type="hidden" name="user_defined_group_common_permission[<?php echo $user_defined_group_common_permission['role_id']; ?>][role_id]" value="<?php echo $user_defined_group_common_permission['role_id']; ?>" />
                                <input type="hidden" name="user_defined_group_common_permission[<?php echo $user_defined_group_common_permission['role_id']; ?>][rank_id]" value="<?php echo $user_defined_group_common_permission['rank_id']; ?>" />
                            </td>
                            <td><input type="checkbox" name="user_defined_group_common_permission[<?php echo $user_defined_group_common_permission['role_id']; ?>][view_forum]" value="1" <?php echo isset($user_defined_group_common_permission['view_forum']) && $user_defined_group_common_permission['view_forum'] ? 'checked="checked"' : ''; ?> /></td>
                            <td><input type="checkbox" name="user_defined_group_common_permission[<?php echo $user_defined_group_common_permission['role_id']; ?>][topic_view]" value="1" <?php echo isset($user_defined_group_common_permission['topic_view']) && $user_defined_group_common_permission['topic_view'] ? 'checked="checked"' : ''; ?> /></td>
                            <td><input type="checkbox" name="user_defined_group_common_permission[<?php echo $user_defined_group_common_permission['role_id']; ?>][topic_publish]" value="1" <?php echo isset($user_defined_group_common_permission['topic_publish']) && $user_defined_group_common_permission['topic_publish'] ? 'checked="checked"' : ''; ?> /></td>
                            <td><input type="checkbox" name="user_defined_group_common_permission[<?php echo $user_defined_group_common_permission['role_id']; ?>][topic_reply]" value="1" <?php echo isset($user_defined_group_common_permission['topic_reply']) && $user_defined_group_common_permission['topic_reply'] ? 'checked="checked"' : ''; ?> /></td>
                            <td><input type="checkbox" name="user_defined_group_common_permission[<?php echo $user_defined_group_common_permission['role_id']; ?>][post_delete]" value="1" <?php echo isset($user_defined_group_common_permission['post_delete']) && $user_defined_group_common_permission['post_delete'] ? 'checked="checked"' : ''; ?> /></td>
                            <td><input type="checkbox" name="user_defined_group_common_permission[<?php echo $user_defined_group_common_permission['role_id']; ?>][post_edit]" value="1" <?php echo isset($user_defined_group_common_permission['post_edit']) && $user_defined_group_common_permission['post_edit'] ? 'checked="checked"' : ''; ?> /></td>
                            <td><input type="checkbox" name="user_defined_group_common_permission[<?php echo $user_defined_group_common_permission['role_id']; ?>][poll_publish]" value="1" <?php echo isset($user_defined_group_common_permission['poll_publish']) && $user_defined_group_common_permission['poll_publish'] ? 'checked="checked"' : ''; ?> /></td>
                            <td><input type="checkbox" name="user_defined_group_common_permission[<?php echo $user_defined_group_common_permission['role_id']; ?>][poll_edit]" value="1" <?php echo isset($user_defined_group_common_permission['poll_edit']) && $user_defined_group_common_permission['poll_edit'] ? 'checked="checked"' : ''; ?> /></td>
                            <td><input type="checkbox" name="user_defined_group_common_permission[<?php echo $user_defined_group_common_permission['role_id']; ?>][poll_vote]" value="1" <?php echo isset($user_defined_group_common_permission['poll_vote']) && $user_defined_group_common_permission['poll_vote'] ? 'checked="checked"' : ''; ?> /></td>
                            <td><input type="checkbox" name="user_defined_group_common_permission[<?php echo $user_defined_group_common_permission['role_id']; ?>][posting_approval]" value="1" <?php echo isset($user_defined_group_common_permission['posting_approval']) && $user_defined_group_common_permission['posting_approval'] ? 'checked="checked"' : ''; ?> /></td>
                            <td><input type="checkbox" name="user_defined_group_common_permission[<?php echo $user_defined_group_common_permission['role_id']; ?>][posting_bbcode]" value="1" <?php echo isset($user_defined_group_common_permission['posting_bbcode']) && $user_defined_group_common_permission['posting_bbcode'] ? 'checked="checked"' : ''; ?> /></td>
                            <td><input type="checkbox" name="user_defined_group_common_permission[<?php echo $user_defined_group_common_permission['role_id']; ?>][posting_bbcode_img]" value="1" <?php echo isset($user_defined_group_common_permission['posting_bbcode_img']) && $user_defined_group_common_permission['posting_bbcode_img'] ? 'checked="checked"' : ''; ?> /></td>
                            <td><input type="checkbox" name="user_defined_group_common_permission[<?php echo $user_defined_group_common_permission['role_id']; ?>][posting_bbcode_flash]" value="1" <?php echo isset($user_defined_group_common_permission['posting_bbcode_flash']) && $user_defined_group_common_permission['posting_bbcode_flash'] ? 'checked="checked"' : ''; ?> /></td>
                            <td><input type="checkbox" name="user_defined_group_common_permission[<?php echo $user_defined_group_common_permission['role_id']; ?>][posting_bbcode_url]" value="1" <?php echo isset($user_defined_group_common_permission['posting_bbcode_url']) && $user_defined_group_common_permission['posting_bbcode_url'] ? 'checked="checked"' : ''; ?> /></td>
                            <td><input type="checkbox" name="user_defined_group_common_permission[<?php echo $user_defined_group_common_permission['role_id']; ?>][posting_smiles]" value="1" <?php echo isset($user_defined_group_common_permission['posting_smiles']) && $user_defined_group_common_permission['posting_smiles'] ? 'checked="checked"' : ''; ?> /></td>
                        </tr>
                        <?php } ?>
                        <?php } ?>
                        <?php if($member_common_permissions){ ?>
                        <tr>
                            <td class="permission-group" colspan="16"><strong><?php echo $entry_registered_member_group; ?></strong></td>
                        </tr>
                        <?php foreach ($member_common_permissions as $member_common_permission) { ?>
                        <tr>
                            <td class="left">
                                <input type="checkbox" name="" value="1" />
                                <?php echo $member_common_permission['rank_title']; ?>
                                <input type="hidden" name="member_common_permission[<?php echo $member_common_permission['rank_id']; ?>][rank_title]" value="<?php echo $member_common_permission['rank_title']; ?>" />
                                <input type="hidden" name="member_common_permission[<?php echo $member_common_permission['rank_id']; ?>][role_id]" value="<?php echo $member_common_permission['role_id']; ?>" />
                                <input type="hidden" name="member_common_permission[<?php echo $member_common_permission['rank_id']; ?>][rank_id]" value="<?php echo $member_common_permission['rank_id']; ?>" />
                            </td>
                            <td><input type="checkbox" name="member_common_permission[<?php echo $member_common_permission['rank_id']; ?>][view_forum]" value="1" <?php echo isset($member_common_permission['view_forum']) && $member_common_permission['view_forum'] ? 'checked="checked"' : ''; ?> /></td>
                            <td><input type="checkbox" name="member_common_permission[<?php echo $member_common_permission['rank_id']; ?>][topic_view]" value="1" <?php echo isset($member_common_permission['topic_view']) && $member_common_permission['topic_view'] ? 'checked="checked"' : ''; ?> /></td>
                            <td><input type="checkbox" name="member_common_permission[<?php echo $member_common_permission['rank_id']; ?>][topic_publish]" value="1" <?php echo isset($member_common_permission['topic_publish']) && $member_common_permission['topic_publish'] ? 'checked="checked"' : ''; ?> /></td>
                            <td><input type="checkbox" name="member_common_permission[<?php echo $member_common_permission['rank_id']; ?>][topic_reply]" value="1" <?php echo isset($member_common_permission['topic_reply']) && $member_common_permission['topic_reply'] ? 'checked="checked"' : ''; ?> /></td>
                            <td><input type="checkbox" name="member_common_permission[<?php echo $member_common_permission['rank_id']; ?>][post_delete]" value="1" <?php echo isset($member_common_permission['post_delete']) && $member_common_permission['post_delete'] ? 'checked="checked"' : ''; ?> /></td>
                            <td><input type="checkbox" name="member_common_permission[<?php echo $member_common_permission['rank_id']; ?>][post_edit]" value="1" <?php echo isset($member_common_permission['post_edit']) && $member_common_permission['post_edit'] ? 'checked="checked"' : ''; ?> /></td>
                            <td><input type="checkbox" name="member_common_permission[<?php echo $member_common_permission['rank_id']; ?>][poll_publish]" value="1" <?php echo isset($member_common_permission['poll_publish']) && $member_common_permission['poll_publish'] ? 'checked="checked"' : ''; ?> /></td>
                            <td><input type="checkbox" name="member_common_permission[<?php echo $member_common_permission['rank_id']; ?>][poll_edit]" value="1" <?php echo isset($member_common_permission['poll_edit']) && $member_common_permission['poll_edit'] ? 'checked="checked"' : ''; ?> /></td>
                            <td><input type="checkbox" name="member_common_permission[<?php echo $member_common_permission['rank_id']; ?>][poll_vote]" value="1" <?php echo isset($member_common_permission['poll_vote']) && $member_common_permission['poll_vote'] ? 'checked="checked"' : ''; ?> /></td>
                            <td><input type="checkbox" name="member_common_permission[<?php echo $member_common_permission['rank_id']; ?>][posting_approval]" value="1" <?php echo isset($member_common_permission['posting_approval']) && $member_common_permission['posting_approval'] ? 'checked="checked"' : ''; ?> /></td>
                            <td><input type="checkbox" name="member_common_permission[<?php echo $member_common_permission['rank_id']; ?>][posting_bbcode]" value="1" <?php echo isset($member_common_permission['posting_bbcode']) && $member_common_permission['posting_bbcode'] ? 'checked="checked"' : ''; ?> /></td>
                            <td><input type="checkbox" name="member_common_permission[<?php echo $member_common_permission['rank_id']; ?>][posting_bbcode_img]" value="1" <?php echo isset($member_common_permission['posting_bbcode_img']) && $member_common_permission['posting_bbcode_img'] ? 'checked="checked"' : ''; ?> /></td>
                            <td><input type="checkbox" name="member_common_permission[<?php echo $member_common_permission['rank_id']; ?>][posting_bbcode_flash]" value="1" <?php echo isset($member_common_permission['posting_bbcode_flash']) && $member_common_permission['posting_bbcode_flash'] ? 'checked="checked"' : ''; ?> /></td>
                            <td><input type="checkbox" name="member_common_permission[<?php echo $member_common_permission['rank_id']; ?>][posting_bbcode_url]" value="1" <?php echo isset($member_common_permission['posting_bbcode_url']) && $member_common_permission['posting_bbcode_url'] ? 'checked="checked"' : ''; ?> /></td>
                            <td><input type="checkbox" name="member_common_permission[<?php echo $member_common_permission['rank_id']; ?>][posting_smiles]" value="1" <?php echo isset($member_common_permission['posting_smiles']) && $member_common_permission['posting_smiles'] ? 'checked="checked"' : ''; ?> /></td>
                        </tr>
                        <?php } ?>
                        <?php } ?>
                        </tbody>
                    </table>
                </div>
            </form>
        </div>
    </div>
</div>
<script type="text/javascript" src="view/javascript/ckeditor/ckeditor.js"></script>
<script type="text/javascript"><!--
<?php foreach ($languages as $language) { ?>
CKEDITOR.replace('rule<?php echo $language['language_id']; ?>', {
    filebrowserBrowseUrl: 'index.php?route=common/filemanager&token=<?php echo $token; ?>',
    filebrowserImageBrowseUrl: 'index.php?route=common/filemanager&token=<?php echo $token; ?>',
    filebrowserFlashBrowseUrl: 'index.php?route=common/filemanager&token=<?php echo $token; ?>',
    filebrowserUploadUrl: 'index.php?route=common/filemanager&token=<?php echo $token; ?>',
    filebrowserImageUploadUrl: 'index.php?route=common/filemanager&token=<?php echo $token; ?>',
    filebrowserFlashUploadUrl: 'index.php?route=common/filemanager&token=<?php echo $token; ?>'
});
<?php } ?>

$('select[name=\'type\']').live('change', function() {
    if (this.value == 1) {
        $('.optional').show();
        $('.tag_per').css({ 'visibility': 'visible'});
    }else {
        $('.optional').hide();
        $('.tag_per').css({ 'visibility': 'hidden'});
    }
});
//--></script>
<script type="text/javascript"><!--
$.widget('custom.catcomplete', $.ui.autocomplete, {
    _renderMenu: function(ul, items) {
        var self = this, currentCategory = '';

        $.each(items, function(index, item) {
            self._renderItem(ul, item);
        });
    }
});

$('input[name=\'forum_mod_name\']').catcomplete({
    delay: 0,
    source: function(request, response) {
        $.ajax({
            url: 'index.php?route=community/forum/autocomplete&token=<?php echo $token; ?>&filter_name=' +  encodeURIComponent(request.term),
            dataType: 'json',
            success: function(json) {
                response($.map(json, function(item) {
                    return {
                        label: item.username,
                        value: item.user_id
                    }
                }));
            }
        });
    },
    select: function(event, ui) {
        $('input[name=\'forum_mod_name\']').val(ui.item.label);

        return false;
    }
});
//--></script>
<script type="text/javascript"><!--
var tag_row = <?php echo $tag_row; ?>;

function addTag() {
    html  = '<tbody id="tag-row' + tag_row + '">';
    html += '<tr>';
    html += '<td class="left"><input type="hidden" name="tag[' + tag_row + '][topic_category_id]" value="" />';
<?php foreach ($languages as $language) { ?>
    html += '<input type="text" name="tag[' + tag_row + '][topic_category_title][<?php echo $language['language_id']; ?>]" value="" /> <img src="view/image/flags/<?php echo $language['image']; ?>" title="<?php echo $language['name']; ?>" /><br />';
    <?php } ?>
    html += '</td>';
    html += '<td class="right"><input type="text" name="tag[' + tag_row + '][sort_order_id]" value="" size="1" /></td>';
    html += '<td class="left"><a onclick="$(\'#tag-row' + tag_row + '\').remove();" class="button"><?php echo $button_remove; ?></a></td>';
    html += '</tr>';
    html += '</tbody>';

    $('#topic-tag tfoot').before(html);

    tag_row++;
}
//--></script>
<script type="text/javascript"><!--
$('#tabs a').tabs();
$('#languages a').tabs();

function checkAll(obj){
    var bool = $(obj).attr("checked");

    $.each($(obj).parent().next().find("input"),function(){
        $(this).attr("checked",bool);
    });
}

//--></script>
<?php echo $footer; ?>